LAGOS Analysis

Loading in data

First download and then specifically grab the locus (or site lat longs)

# #Lagos download script
LAGOSNE::lagosne_get(dest_folder = LAGOSNE:::lagos_path())


#Load in lagos
lagos <- lagosne_load()

#Grab the lake centroid info
lake_centers <- lagos$locus

Convert to spatial data

#Look at the column names
#names(lake_centers)

#Look at the structure
#str(lake_centers)

#View the full dataset
#View(lake_centers %>% slice(1:100))

spatial_lakes <- st_as_sf(lake_centers,coords=c('nhd_long','nhd_lat'),
                          crs=4326) %>%
  st_transform(2163)

#Subset for plotting
subset_spatial <- spatial_lakes %>%
  slice(1:100) 

subset_baser <- spatial_lakes[1:100,]

#Dynamic mapviewer
mapview(subset_spatial)

Subset to only Minnesota

states <- us_states()

#Plot all the states to check if they loaded
#mapview(states)
minnesota <- states %>%
  filter(name == 'Minnesota') %>%
  st_transform(2163)

#Subset lakes based on spatial position
minnesota_lakes <- spatial_lakes[minnesota,]

#Plotting the first 1000 lakes
minnesota_lakes %>%
  arrange(-lake_area_ha) %>%
    slice(1:1000) %>%
  mapview(.,zcol = 'lake_area_ha')

In-Class work

1) Show a map outline of Iowa and Illinois (similar to Minnesota map upstream)

#Subset to Iowa
Iowa <- states %>%
  filter(name == 'Iowa') %>%
  st_transform(2163)

#Subset to Illinois
Illinois <- states %>%
  filter(name == 'Illinois') %>%
  st_transform(2163)

#Combine both dataframes
Iowa_and_Illinois <- combine(Iowa,Illinois)

mapview(Iowa_and_Illinois)

2) Subset LAGOS data to these sites, how many sites are in Illinois and Iowa combined? How does this compare to Minnesota?

#Subset lakes based on spatial position
Iowa_and_Illinois_lakes <- spatial_lakes[Iowa_and_Illinois,]

There are fewer lake sites in Illinois and Iowa combined compared to Minnesota. Iowa and Illinois have a combined 16466 observations, while Minnesota alone has 29038 observations.

3) What is the distribution of lake size in Iowa vs. Minnesota?

  • Here I want to see a histogram plot with lake size on x-axis and frequency on y axis (check out geom_histogram)
#Subset just Iowa
Iowa__lakes <- spatial_lakes[Iowa,]
#Create Iowa Histogram
ggplot(data=Iowa__lakes,aes(x=lake_area_ha)) +
  geom_histogram() +
  scale_x_log10() +
  xlab('Log Scale - Iowa Lake Area (ha)')

#Create Minnesota Histogram
ggplot(data=minnesota_lakes,aes(x=lake_area_ha)) +
  geom_histogram() +
  scale_x_log10() +
  xlab('Log Scale - Minnesota Lake Area (ha)')

Although small lakes dominate both states, Minnesota has more larger lakes compared to Iowa.

4) Make an interactive plot of lakes in Iowa and Illinois and color them by lake area in hectares

#Plotting the first 1000 lakes
Iowa_and_Illinois_lakes %>%
  arrange(-lake_area_ha) %>%
  slice(1:1000) %>%
  mapview(.,zcol = 'lake_area_ha')

5) What other data sources might we use to understand how reservoirs and natural lakes vary in size in these three states?

Mapping groundwater wells by water level could illustrate whether there’s a relationship between groundwater and reservoir/lake size. Additionally, precipitation collection sites for both rain and snow could be compared to determine whether a relationship exists for reservoir/lake size.